package cn.net.cfss.fgbp.provider.manage.utils;

import org.apache.commons.lang.StringUtils;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author wutao
 * @version 1.0
 * @date 2021/3/5 14:31
 */
public class DateUtil {

    public static boolean isDate(String sDate, String format) {
        if (StringUtils.isBlank(sDate)) {
            return false;
        }
        DateFormat formatter = new SimpleDateFormat(format);
        try {
            Date date = formatter.parse(sDate);
            return sDate.equals(formatter.format(date));
        } catch (Exception e) {
            return false;
        }
    }

    public static String format(Date date, String format) {

        if (date == null) {
            return "";
        }
        DateFormat formatter = new SimpleDateFormat(format);

        String formatDate = formatter.format(date);
        return formatDate;
    }





}
